package com.inossem.warehousemanage_tv.fragment;

import android.os.Bundle;

import com.inossem.warehousemanage_tv.R;
import com.orhanobut.logger.Logger;
import com.tencent.smtt.sdk.WebSettings;
import com.tencent.smtt.sdk.WebStorage;
import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient;

/**
 * WebView
 *
 * @author 詹建宇
 * @time on 2019/2/13 11:04
 * @email jianyu.zhan@inossem.com
 */
public class WebFragment extends BaseFragment {

    private WebView webView;

    @Override
    public int initLayout() {
        return R.layout.fragment_web;
    }

    @Override
    public void initView() {
        webView = mView.findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setSupportZoom(true);
        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        webView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return false;
            }
        });
    }

    @Override
    public void initData() {
        WebStorage.getInstance().deleteAllData();
        webView.clearCache(true);
        Bundle bundle = getArguments();
        if (bundle == null) return;
        String url = bundle.getString("url");
        Logger.i(String.valueOf(url));
        webView.loadUrl(url);
    }

    @Override
    public void initClick() {

    }
}
